### Project 21 Magnetic Detection **1. Overview** In this project, you will learn how to use our hall magnetic sensor to control 5\*5 LED of micro:bit display different images. At the same time, both the LED dot matrix of Micro: bit and the CoolTerm serial port monitor display the digital signals read by the Hall magnetic sensor to detect whether the surrounding magnetic field exists. **2.Components Required** - Micro:bit Main Board\*1 - Keyestudio Edge Connector IO Breakout Board for Micro:bit\*1 - USB Cable\*1 - Keyestudio Hall Magnetic Sensor\*1 - Keyestudio micro bit honeycomb Digital LED Module\*1 - Alligator Clip Wire\*6 **3.Component Introduction** ![](media/image-20260128143140804.png) **About Keyestudio micro bit honeycomb hall magnetic sensor** The Keyestudio micro bit honeycomb hall magnetic sensor is fully compatible with micro bit control board. In the experiment, we connect it with the micro: bit by a crocodile clip. There are 6 sockets on it, 2 G, 2 V and 2 S are connected. Additionally, G is GND, VV is VCC, and S is the signal end of the module. During the test, we test the analog value of S end via micro: bit control board. The analog value reading is in Low Level(0) when the nearby magnetic field is detected or it is in High Level(1). **4.Technical Parameters** - Working voltage: DC 3.0-5V - Working current: 60mA - Maximum power: 300mW - Working temperature: -25 ℃ \~-65 ℃ - Dimension: 30mm \* 27mm \* 5mm - Weight: 2.0g - Environmental attributes: ROHS **5.Connection Diagram** Attach the main board to Keyestudio Edge Connector IO Breakout Board for Micro:bit; Connect the keyestudio micro bit honeycomb hall magnetic sensor to the shield with 3 Alligator clip cables; Ring S to P0, V to 3V, and G to GND. Connect the keyestudio micro bit digital LED module to the shield with 3 Alligator clip cables. Ring S to P1, V to 3V, and G to GND. Interface the micro:bit to your computer with a micro USB cable. ![](media/image-20260128143252625.png) **6.Coding** So now let's move to coding. Below are some steps to follow. Open the [https://makecode.micro:bit.org/\#editor](https://makecode.microbit.org/#editor) to write your code. Microsoft MakeCode is actually a platform that allows us to code for a micro:bit, and also provides an interactive simulator where we can debug and run our code, and will be able to see what to expect out right there on the site. Go to MakeCode and choose **My Projects** and click on **New Projects**. If you want to see the codes behind, then you can click on JavaScript and it will display JavaScript code there in IDE. ![](media/image-20260128143319465.png) **7.The following code is for your reference** ![](media/image-20260128143343462.png) **8.Test Results** Wire according to connection diagram and upload the test code successfully. Open CoolTerm →click Options →click SerialPort to set COM port and set baud rate to 115200→click OK→click Connect. When the hall magnetic sensor detects magnetic field nearby, both the LED dot matrix of micro bit and the serial monitor display Low Level(0) and the LED is on. Otherwise, they both show High Level(1) and the LED turns off. The serial monitor of CoolTerm shows as below. ![](media/image-20260128143410560.png)